home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PVDRIVER / DVIWN281.ZIP / GENPK.BAT < prev    next >
DOS Batch File  |  1993-09-30  |  7KB  |  205 lines

  1. @echo off
  2. rem    This is a sample batch file to run metafont, convert the GF file to
  3. rem    the PK format and store the PK font in the appropriate directory. It
  4. rem    is meant to be called by dviwin and that's the reason for the absence
  5. rem    of any parameter checking. It also assumes that metafont and gftopk
  6. rem    are operating properly. This sample file attempts to cover as many
  7. rem    devices as possible; you will probably get better and faster results
  8. rem    if you write a smaller and more specialized batch file.
  9. rem
  10. rem    The plain base is a prerequisite: make sure that you generate it by
  11. rem    running inimf on plain.mf, then input the file modes.mf and finally
  12. rem    dump the format file. If you don't know what I am talking about,
  13. rem    please read the documentation that comes with the metafont program,
  14. rem    as well as the Metafont book. You MAY need to modify this batch file
  15. rem    if the name of your metafont program is not mf.
  16. rem
  17. rem    You WILL need to modify the routine to place the PK files in the
  18. rem    proper directory; the current method uses the environment variable
  19. rem    DVIFONTS which is assumed to contain the base directory for the PK
  20. rem    fonts. Any square-pixel fonts are assumed to be stored in the
  21. rem    directories  $(DVIFONTS)\X  where X is the resolution of the font.
  22. rem    Non-square-pixel fonts are assumed to stored in the directories
  23. rem    $(DVIFONTS)\XxY where X is the horizontal resolution and Y is the
  24. rem    vertical resolution.
  25. rem
  26. rem    It is trivial to modify the name of metafont and the base directory;
  27. rem    just select the proper values for the first two statements after
  28. rem    these comments. If you use another directory structure, you need
  29. rem    to modify the next two statements.
  30. rem
  31. rem    You may also need to do more modifications if you have other devices;
  32. rem    this batch file generates fonts for the screen, 300dpi laser and
  33. rem    inkjet printers, 600dpi laserjets, as well as 9-pin and 24-pin dot
  34. rem    matrix printers. If you want to use another device, you will have to
  35. rem    understand the code below and modify it accordingly (maybe you will
  36. rem    want to rewrite the code in a compiled language to improve the speed,
  37. rem    the error handling and avoid all the ugly gotos). If you want to use
  38. rem    a 9-pin dot matrix printer at 120x144dpi or 240x144dpi, add the
  39. rem    following lines to the file modes.mf and regenerate the plain base.
  40. rem
  41. rem    mode_def epsmed =            % Epson-FX at 240x144dpi
  42. rem        mode_param (pixels_per_inch, 240);
  43. rem        mode_param (aspect_ratio, 144 / pixels_per_inch);
  44. rem        EpsonMXFX_;
  45. rem    enddef;
  46. rem
  47. rem    mode_def epswlo =            % Epson-FX at 120x144dpi
  48. rem        mode_param (pixels_per_inch, 120);
  49. rem        mode_param (aspect_ratio, 144 / pixels_per_inch);
  50. rem        EpsonMXFX_;
  51. rem    enddef;
  52. rem
  53. rem    If metafont does not recognize any other modes, it will generate
  54. rem    its standard proofing fonts which are HUGE and inappropriate for
  55. rem    your device. In that case, get the file modes.mf from CTAN and
  56. rem    generate the plain base again using the command:
  57. rem        inimf plain;input modes;dump
  58. rem    Then you need to copy plain.bas to the appropriate directory. You
  59. rem    may need to replace "inimf" by "mf -i" for some Metafont versions.
  60. rem
  61. rem    Here are the parameters passed by dviwin:
  62. rem        %1:    fontname    (truncated to 8 chars)
  63. rem        %2:    magstep
  64. rem        %3:    xres        (hor. resolution of font)
  65. rem        %4:    yres            (vert. resolution of font)
  66. rem        %5:    xbase        (base hor. resolution)
  67. rem        %6:    ybase        (base vert. resolution)
  68. rem        %7:    drive        (of current dvi file)
  69. rem        %8:    path        (of current dvi file)
  70. rem        %9:    gf extension    (truncated to 3 chars)
  71. rem
  72. rem    In most cases, you will only need to modify the next four statements:
  73.  
  74. set MF=mf
  75. set PK_BASE=%DVIFONTS%
  76. set PK_DIR=%PK_BASE%\%3x%4
  77. if %5==%6 set PK_DIR=%PK_BASE%\%3
  78.  
  79. rem    If the font already exists, don't do anything
  80.  
  81. if exist %PK_DIR%\%1.pk goto GETOUT
  82.  
  83. rem    If you want to switch to the directory of the current dvi file,
  84. rem    uncomment the next two statements. This is useful if you prefer
  85. rem    to keep some mf sources in the dvi file directory instead of the
  86. rem    MFINPUTS directory.
  87. rem %7:
  88. rem cd %8
  89.  
  90. rem    Devices with non-square pixels; we support the following modes:
  91. rem    epsdraft (9-pin 120x72dpi), epswlo (9-pin 120x144dpi), epsmed
  92. rem    (9-pin 240x144dpi), epsonfx (9-pin 240x216dpi) and lqmedres
  93. rem    (24-pin 360x180dpi)
  94.  
  95. if %5==%6 goto SQUARE_PIXELS
  96. set PK_MAG=%2
  97. set PK_DEV=
  98. if %6==72    set PK_DEV=epsdraft
  99. if %6==216    set PK_DEV=epsonfx
  100. if %6==180    set PK_DEV=lqmedres
  101. if %6==144    goto FX_LOMED
  102. if +%PK_DEV%==+    goto UNKNOWN
  103. goto DO_IT
  104. :FX_LOMED
  105. if %5==120    set PK_DEV=epswlo
  106. if %5==240    set PK_DEV=epsmed
  107. if +%PK_DEV%==+    goto UNKNOWN
  108. goto DO_IT
  109.  
  110. rem    Devices with square pixels. The current code supports the resolutions
  111. rem    used by the Beebe drivers for the screen, 300dpi and 400dpi laser
  112. rem    and inkjet printers, 600dpi laserjets, 24-pin printers at 180x180
  113. rem    and 360x360dpi.
  114.  
  115. :SQUARE_PIXELS
  116. set PK_DEV=
  117. set PK_MAG=
  118. if %3==58    set PK_MAG=-9
  119. if %3==64    set PK_MAG=-8.5
  120. if %3==70    set PK_MAG=-8
  121. if %3==76    set PK_MAG=-7.5
  122. if %3==84    set PK_MAG=-7
  123. if %3==92    set PK_MAG=-6.5
  124. if %3==100    set PK_MAG=-6
  125. if %3==110    set PK_MAG=-5.5
  126. if %3==121    set PK_MAG=-5
  127. if %3==132    set PK_MAG=-4.5
  128. if %3==145    set PK_MAG=-4
  129. if %3==158    set PK_MAG=-3.5
  130. if %3==174    set PK_MAG=-3
  131. if %3==190    set PK_MAG=-2.5
  132. if %3==208    set PK_MAG=-2
  133. if %3==228    set PK_MAG=-1.5
  134. if %3==250    set PK_MAG=-1
  135. if %3==274    set PK_MAG=-0.5
  136. if %3==300    set PK_MAG=0
  137. if %3==329    set PK_MAG=0.5
  138. if %3==360    set PK_MAG=1
  139. if %3==394    set PK_MAG=1.5
  140. if %3==432    set PK_MAG=2
  141. if %3==473    set PK_MAG=2.5
  142. if %3==518    set PK_MAG=3
  143. if %3==568    set PK_MAG=3.5
  144. if %3==622    set PK_MAG=4
  145. if %3==681    set PK_MAG=4.5
  146. if %3==746    set PK_MAG=5
  147. if %3==818    set PK_MAG=5.5
  148. if %3==896    set PK_MAG=6
  149. if %3==981    set PK_MAG=6.5
  150. if %3==1075    set PK_MAG=7
  151. if %3==1178    set PK_MAG=7.5
  152. if %3==1290    set PK_MAG=8
  153. if +%PK_MAG%==+ goto OTHER_SQ
  154. set PK_DEV=hplaser
  155. goto DO_IT
  156. :OTHER_SQ
  157. set PK_MAG=%2
  158. if %5==180    set PK_DEV=lqlores
  159. if %5==360    set PK_DEV=lqhires
  160. if %5==300    set PK_DEV=hplaser
  161. if %5==400    set PK_DEV=nexthi
  162. if %5==600    set PK_DEV=ljiv
  163. if +%PK_DEV%==+ goto UNKNOWN
  164.  
  165. :DO_IT
  166. echo on
  167. %MF% \scrollmode;mode:=%PK_DEV%;mag:=magstep(%PK_MAG%);input %1
  168. @echo off
  169. if errorlevel 1 goto ERROR_EXIT
  170.  
  171. rem    DOS will complain if the directories already exist. Just ignore it.
  172. md %PK_BASE%
  173. md %PK_DIR%
  174.  
  175. rem    This stupid trick is necessary because some versions of Metafont
  176. rem    use an extension of NNNgf (where NNN is the hor. resolution) and
  177. rem    truncate it to 3 chars. while other versions use just NNN which
  178. rem    they also truncate to 3 chars.
  179. set GF_EXT=%3
  180. if exist %1.%9 set GF_EXT=%9
  181.  
  182. gftopk %1.%GF_EXT%  %PK_DIR%\%1.pk
  183. del %1.%GF_EXT%
  184. del %1.log
  185.  
  186. rem    If you want to copy the TFM file to an appropriate directory,
  187. rem    here is the place to do it.
  188. del %1.tfm
  189. goto GETOUT
  190.  
  191. :UNKNOWN
  192. echo I don't know the metafont mode for this device. Please
  193. echo add this information to the file %0
  194.  
  195. :ERROR_EXIT
  196.  
  197. rem    The next line creates a small file in the TEMP directory. When
  198. rem    running under NT, this signals the error to the "genallnt.bat"
  199. rem    file, so it doesn't call dviwin again.
  200.  
  201. echo ERROR > %TEMP%\error$_$
  202. pause
  203.  
  204. :GETOUT
  205.